package me.helllp.dake.generator.meta.core;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import com.squareup.javapoet.TypeSpec;

import lombok.Getter;
import lombok.Setter;

/**
 * 接口生成
 * 
 * @author 林晓明
 *
 */
@Getter
@Setter
public class SmartInterface {
	private String name;
	
	private String desc;
	
	private List<SmartMethod> methods;
	
	public TypeSpec.Builder builder() {
		return TypeSpec.interfaceBuilder(name).addMethods(
					Optional.ofNullable(methods).map(item -> {
						return item.stream().map(parameter -> parameter.builder().build()).collect(Collectors.toList());
					}).orElse(Collections.emptyList())
				).addJavadoc(desc);
	}
}
